package org.example;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;

public class Main {
    public static void main(String[] args) {

        String f = "D:\\x3d\\tool\\aspose-cad-21.11.jar";
        try {
            //这一步是完整的jar包路径,选择自己解压的jar目录
            ClassPool.getDefault().insertClassPath(f);
            CtClass zzZJJClass = ClassPool.getDefault().getCtClass("com.aspose.cad.internal.ok.bY");
            CtMethod[] methodA = zzZJJClass.getDeclaredMethods();
            for (CtMethod ctMethod : methodA) {
                CtClass[] ps = ctMethod.getParameterTypes();
                if (ps.length == 1 && ps[0].getName().contains("InputStream") && ctMethod.getName().equals("a")) {
                    System.out.println("ps[0].getName==" + ps[0].getName());
                    ctMethod.setBody("{" +
                            "int i = 0;\n" +
                            "    try {\n" +
                            "      javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();\n" +
                            "      javax.xml.parsers.DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\n" +
                            "      org.w3c.dom.Document document = documentBuilder.parse($1);\n" +
                            "      com.aspose.cad.internal.ok.aO.a a = a(document);\n" +
                            "      b = this;\n" +
                            "      com.aspose.cad.internal.ok.bz.a();\n" +
                            "      com.aspose.cad.internal.ok.aQ.b();\n" +
                            "       int x = this.a(i) + 1;" +
                            "      com.aspose.cad.internal.ok.aQ.a = com.aspose.cad.internal.ok.aP.c[x];\n" +
                            "      com.aspose.cad.internal.ok.aQ.b();\n" +
                            "      com.aspose.cad.internal.ok.aQ.d = a.d;\n" +
                            "    } catch (Throwable throwable) {\n" +
                            "       return 0;" +
                            "    } \n" +
                            "    return i;" +
                            "}");
                }
                if (ps.length == 3 && ps[0].getName().contains("Node") && ctMethod.getName().equals("a")) {
                    System.out.println("ps[0].getName==" + ps[0].getName());
                    ctMethod.setBody("{" +
                            "return true;" +
                            "}");
                }
            }
            //这一步就是将破译完的代码放在桌面上
            zzZJJClass.writeFile("D:\\x3d\\tool\\aspose-cad-21.11");
        } catch (Exception e) {
            System.out.println("错误==" + e);
        }

    }
}